package com.ysqcould.revita.service.impl;


import com.ysqcould.common.utils.DateUtils;
import com.ysqcould.revita.domain.GslNotice;
import com.ysqcould.revita.mapper.GslNoticeMapper;
import com.ysqcould.revita.service.IGslNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 乡村轮播图Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@Service
public class GslNoticeServiceImpl implements IGslNoticeService
{
    @Autowired
    private GslNoticeMapper gslNoticeMapper;

    /**
     * 查询乡村轮播图
     * 
     * @param id 乡村轮播图主键
     * @return 乡村轮播图
     */
    @Override
    public GslNotice selectGslNoticeById(Long id)
    {
        return gslNoticeMapper.selectGslNoticeById(id);
    }

    /**
     * 查询乡村轮播图列表
     * 
     * @param gslNotice 乡村轮播图
     * @return 乡村轮播图
     */
    @Override
    public List<GslNotice> selectGslNoticeList(GslNotice gslNotice)
    {
        return gslNoticeMapper.selectGslNoticeList(gslNotice);
    }

    /**
     * 新增乡村轮播图
     * 
     * @param gslNotice 乡村轮播图
     * @return 结果
     */
    @Override
    public int insertGslNotice(GslNotice gslNotice)
    {
        gslNotice.setCreateTime(DateUtils.getNowDate());
        return gslNoticeMapper.insertGslNotice(gslNotice);
    }

    /**
     * 修改乡村轮播图
     * 
     * @param gslNotice 乡村轮播图
     * @return 结果
     */
    @Override
    public int updateGslNotice(GslNotice gslNotice)
    {
        gslNotice.setUpdateTime(DateUtils.getNowDate());
        return gslNoticeMapper.updateGslNotice(gslNotice);
    }

    /**
     * 批量删除乡村轮播图
     * 
     * @param ids 需要删除的乡村轮播图主键
     * @return 结果
     */
    @Override
    public int deleteGslNoticeByIds(Long[] ids)
    {
        return gslNoticeMapper.deleteGslNoticeByIds(ids);
    }

    /**
     * 删除乡村轮播图信息
     * 
     * @param id 乡村轮播图主键
     * @return 结果
     */
    @Override
    public int deleteGslNoticeById(Long id)
    {
        return gslNoticeMapper.deleteGslNoticeById(id);
    }

    @Override
    public int updateStatus(GslNotice notice) {
        GslNotice gslNotice = gslNoticeMapper.selectGslNoticeById(notice.getId());
        gslNotice.setStatus(notice.getStatus());
        int i = gslNoticeMapper.updateGslNotice(gslNotice);
        return i;
    }
}
